package com.appbee.songs.server.service;

import java.util.List;

import com.appbee.core.server.requestfactory.BaseService;
import com.appbee.songs.server.dao.SongDAO;
import com.appbee.songs.server.model.Song;
import com.appbee.songs.server.model.SongFilter;
import com.appbee.songs.server.model.SongListResult;

public class SongService extends BaseService<Song, SongDAO>
{
	public List<Song> findByFilter(SongFilter filter,int start,int size)
	{
		SongDAO songDAO = daoProvider.get();
		List<Song> list = songDAO.findByFilter(filter,start, size);
		return list;
	}
	public SongListResult findByRange(int start,int size)
	{
		int totalCount = totalSize();
		List<Song> list = daoProvider.get().findByRange(start, size);
		SongListResult result = new SongListResult();
		result.setList(list);
		result.setTotalCount(totalCount);
		return result;
	}
	
	public Integer totalSize()
	{
		return daoProvider.get().totalSize();
	}
	
	public Song findById(Long id)
	{
		return daoProvider.get().findById(id);
	}
	
	public Song save(Song bean)
	{
		daoProvider.get().saveAllTransaction(bean);
		return bean;
	}
	
	public void delete(Song song)
	{
		daoProvider.get().delete(song);
	}

	public Integer getMaxNumber()
	{

		return daoProvider.get().getMaxNumber();
	}

	public Song updateNumber(Song song, int number)
	{
		return daoProvider.get().updateNumber(song, number);
	}
}
